package com.chenju.javastatic.controller;

import com.chenju.javastatic.common.response.ResponseEntity;
import com.chenju.javastatic.domain.pojo.Neo4jRequestPoJo;
import com.chenju.javastatic.service.Neo4JService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping(value = "/neo")
public class Neo4jController {
    @Autowired
    private Neo4JService neo4JService;

    @PostMapping(value = "/excuteQuery")
    public ResponseEntity excute(@RequestBody Neo4jRequestPoJo neo4jRequestPoJo){
        if (neo4jRequestPoJo == null || "".equals(neo4jRequestPoJo.getCypherSQL())){
            return ResponseEntity.fail("查询语句为空");
        }
        return ResponseEntity.success(neo4JService.excute(neo4jRequestPoJo.getCypherSQL()));
    }

    @PostMapping(value = "/excuteG6Query")
    public ResponseEntity excuteG6(@RequestBody Neo4jRequestPoJo neo4jRequestPoJo){
        if (neo4jRequestPoJo == null || "".equals(neo4jRequestPoJo.getCypherSQL())){
            return ResponseEntity.fail("查询语句为空");
        }
        return ResponseEntity.success(neo4JService.excuteG6(neo4jRequestPoJo.getCypherSQL()));
    }
}
